package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.generator.entity.TestProjectEntity;
import io.renren.modules.generator.service.TestProjectService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-11-12 13:07:16
 */
@RestController
@RequestMapping("generator/testproject")
public class TestProjectController {
    @Autowired
    private TestProjectService testProjectService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:testproject:list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = testProjectService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:testproject:info")
    public R info(@PathVariable("id") Integer id) {
        TestProjectEntity testProject = testProjectService.getById(id);

        return R.ok().put("testProject", testProject);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:testproject:save")
    public R save(@RequestBody TestProjectEntity testProject) {
        testProjectService.save(testProject);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:testproject:update")
    public R update(@RequestBody TestProjectEntity testProject) {
        testProjectService.updateById(testProject);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:testproject:delete")
    public R delete(@RequestBody Integer[] ids) {
        testProjectService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
